package com.wangyu.springsecuritydemo.controller;

import java.security.Principal;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

/**
 * 用户控制器
 *
 * @author wangyu
 * @Date 2019/2/18 22:52
 * @Version 1.0
 **/
@Controller
public class UserController extends BaseController {

  @GetMapping("/user")
  public String user(@AuthenticationPrincipal Principal principal, Model model) {
    model.addAttribute("username", principal.getName());
    return "user/user";
  }
}
